package team.seekers.hula.question.questionDevelop.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.auth.service.MindUtils;
import team.seekers.hula.question.questionDevelop.entity.dto.QuestionDevelopCreateDTO;
import team.seekers.hula.question.questionDevelop.entity.vo.QuestionDevelopListVO;
import team.seekers.hula.question.questionDevelop.entity.dto.QuestionDevelopUpdateDTO;
import team.seekers.hula.question.questionDevelop.service.QuestionDevelopService;

import java.util.List;
import java.util.Map;

/**
 * @author hbc
 * @since 2021-02-18
 */
@Controller
@ApiResponseBody
@RequestMapping("/question/develop")
public class QuestionDevelopController {

    @Autowired
    private QuestionDevelopService questionDevelopService;


    @PostMapping("/add")
    public String add(@RequestBody QuestionDevelopCreateDTO createDTO){
        return questionDevelopService.add(createDTO);
    }

    @GetMapping("/delete")
    public void delete(@RequestParam String id){
        questionDevelopService.delete(id);
    }


    @PostMapping("/update")
    public void update(@RequestBody QuestionDevelopUpdateDTO updateVO){
        questionDevelopService.update(updateVO);
    }

    // 分页查询按照赞数排序
    @GetMapping("/listOrderByWind")
    public Map<String, List<QuestionDevelopListVO>> listOrderByWind(String questionId){
        return questionDevelopService.listOrderByWind(questionId, MindUtils.getUserId());
    }
}

